//
//  DataEngine.h
//  MobileOA
//
//  Created by chenxiaojuan on 13-4-16.
//  Copyright (c) 2013年 chenxiaojuan. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ServerEngine.h"
#import "MsgEngine.h"

#import "Contact.h"
#import "Message.h"


#define DE ([DataEngine getInstance])
#define $ ([DataEngine getInstance])

@protocol DEDelegate 

@end

@interface DataEngine : NSObject 

@property(nonatomic,retain)NSString* appId;
@property(nonatomic,readonly)NSString* terminalId;
@property(nonatomic,readonly)NSString* terminalName;
@property(nonatomic,readonly)NSString* osName;
@property(nonatomic,readonly)NSString* osVersion;

@property(nonatomic,retain)NSString* serverName;
@property(nonatomic,retain)NSString* serverProjectName;
@property(nonatomic,retain)NSString* serverPort;
@property(nonatomic,retain)NSString* serverUri;
@property(nonatomic,retain)NSString* msgServerName;
@property(nonatomic,retain)NSString* msgServerPort;
@property(nonatomic,retain)NSString* deviceToken;


@property(nonatomic,retain)NSString* userId;
@property(nonatomic,retain)NSString* userPassword;

@property(nonatomic,retain)id<DEDelegate> delegate;

@property(nonatomic,readonly)NSString* appPath;
@property(nonatomic,readonly)NSString* mainPath;
@property(nonatomic,readonly)NSString* dataPath;
@property(nonatomic,readonly)NSString* cachePath;

@property(nonatomic,retain)NSDictionary* msgTypeToTitle;
@property(nonatomic,retain)NSString* msgBroadcastName;

@property(nonatomic,retain)NSString* fileEngineeUrl;






+(DataEngine*)getInstance;

-(void)reload;
-(void)unload;


-(NSDictionary*)serverCall:(NSString*)cmd params:(NSDictionary*)params callback:(CallbackBlock)callback;
-(NSDictionary*)serverCall:(NSString*)cmd params:(NSDictionary*)params callback:(CallbackBlock)callback needCache:(BOOL)needCache;
-(void)removeRequestCache:(NSString*)name params:(NSDictionary*)params;

-(BOOL)serverCallback:(NSString*)cmd params:(NSDictionary*)params success:(BOOL)success response:(NSDictionary*)response;

-(NSString*)getGlobalVar:(NSString*)key;
-(void)setGlobalVar:(NSString*)key value:(NSString*)value;
-(void)removeGlobalVar:(NSString*)key;

//发送文本消息
-(void)sendMessage:(NSDictionary*)msgContentMap callback:(CallbackBlock)callback;

-(void)recepitMsg:(NSArray*)msgIdList;
-(void)dealRecvMessage:(Message *)message;


-(void)updateLocalDBContacts:(NSDictionary*)txls sessionId:(NSString*)sessionId businessId:(NSString*)businesId sendout:(BOOL)send;

@end
